package com.dong.handler;

import com.dong.response.ResultCode;
import com.dong.response.ResultCodeEnum;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.*;

@Data
// 所有构造方法
@AllArgsConstructor
// 无参构造方法
@NoArgsConstructor
public class BusinessException extends RuntimeException {

    private ResultCode resultCode;

    // 直接构造错误信息的构造异常
    public BusinessException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }
    // 自定义错误信息的构造异常
    public BusinessException(ResultCode resultCode, String customMessage) {
        super(customMessage);
        this.resultCode = resultCode;
        this.resultCode.setErrMsg(customMessage);
    }
    public BusinessException(Integer code, String errMsg) {
        this.code = code;
        this.errMsg = errMsg;
    }
    @ApiModelProperty("状态码")
    private Integer code;

    @ApiModelProperty("错误信息")
    private String errMsg;

}
